package com.wushibo.adddatabackend.controller;

import com.wushibo.adddatabackend.entity.CountryData;
import com.wushibo.adddatabackend.entity.PersonInformation;
import com.wushibo.adddatabackend.entity.ProvinceData;
import com.wushibo.adddatabackend.service.impl.AddDataServiceImpl;
import com.wushibo.adddatabackend.utils.Result;
import com.wushibo.adddatabackend.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/add")
@Api(value = "AddData Controller",tags = "填报疫情数据接口")
public class AddDataController {
    @Autowired
    private AddDataServiceImpl addDataServiceImpl;

    @ApiOperation(value="填报省级疫情数据",notes = "填报数据",httpMethod = "POST")
    @RequestMapping("/provincedata")
    public Result addprovincedata(@RequestBody ProvinceData provinceData){
        int i=addDataServiceImpl.addProvinceData(provinceData);
        if(i==1){
            return ResultUtil.success("省级疫情数据填报成功");
        }else{
            return ResultUtil.error("填报省级数据失败");
        }
    }

    @ApiOperation(value="填报国家级疫情数据",notes = "填报数据",httpMethod = "POST")
    @RequestMapping("/countrydata")
    public Result addcountrydata(@RequestBody CountryData countryData){
        int j=addDataServiceImpl.addCountryData(countryData);
        if(j==1){
            return ResultUtil.success("国家级疫情数据填报成功");
        }else{
            return ResultUtil.error("填报国家级数据失败");
        }
    }

    @ApiOperation(value="添加外来人员",notes = "添加外来人员信息",httpMethod = "POST")
    @RequestMapping("/persondata")
    public Result addpersoninformation(@RequestBody PersonInformation personInfor){
        int k=addDataServiceImpl.personInformation(personInfor);
        if(k==1){
            return ResultUtil.success("添加外来人员信息成功");
        }else{
            return ResultUtil.error("添加外来人员信息失败");
        }
    }



}
